let config = require("./config");
import $ from 'jquery'
console.log(this.$parent)
function loginValidate(){
  let id=config.advertiser_id || "";
  $("body > .preloader").addClass("loading").show();
  return new Promise(function(resolve,reject){
    $.ajax({
      url:config.ETL_CONFIG_SERVER+"/dsp/sysuser/baseInfo.do?id="+id,
      type:"GET",
      success:function(data){
        $("body > .preloader").hide();
        data=JSON.parse(data);
        if(data.result=='success'){
          resolve(data);
        }else{
          reject();
        }
      },
      error:function(){
        reject();
      }
    });
  });
}


function getMenu(){
  let id=config.advertiser_id || "1";
  $("body > .preloader").addClass("loading").show();
  return new Promise(function(resolve,reject){
    $.ajax({
      url:config.ETL_CONFIG_SERVER+"/dsp/sysRoleMenu/getRoleMenu.do?userId="+1,
      type:"GET",
      success:function(data){
        $("body > .preloader").hide();
        data=JSON.parse(data);
        if(data.result=='success'){
          resolve(data);
        }
      },
      error:function(){
        $("body > .preloader").hide();
        reject();
      }
    });
  });
}

function checkLoginStatus(){
  return new Promise(function(resolve,reject){
    $.ajax({
      type:"GET",
      url:config.ETL_CONFIG_SERVER+"/dsp/sysuser/checkSign.do",
      success:function(data){
        resolve(data);
      },
      error:function(){
        reject();
      }
    })
  })
}

let obj={
  loginValidate:loginValidate,
  getMenu:getMenu,
  checkLoginStatus:checkLoginStatus
};

export  default obj;
